<?php /* SVN: $Id: index_list.ctp 99 2008-07-09 09:33:42Z rajesh_04ag02 $ */ ?>

<?php if(empty($this->request->params['isAjax'])){ ?>
<div class="banner-content banner-view-content">
	<div class="banner container_24">
		<h2 class="project-title"><?php echo __l('Activities');?></h2>
	</div>
</div>
<?php } ?>
<div class="container_24">
	<?php if(empty($this->request->params['named']['info']) && empty($this->request->params['isAjax'])) { ?>
		<div class="view-banner">
			<div class="ui-tabs">
				<ul class="project-list project-list1 ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all clearfix">
					<?php 
					$class = (empty($this->request->params['named']['type'])) ? 'ui-state-active ui-tabs-selected' : ''; ?>
					<li class="ui-state-default ui-corner-top <?php echo $class; ?>"><?php echo $this->Html->link(__l('Site Activity'), array('controller' => 'activities', 'action' => 'index', 'admin' => false));?></li>
					<?php if($this->Auth->user('id')): ?>
						<?php $class = (!empty($this->request->params['named']['type']) && $this->request->params['named']['type'] == 'myproject') ? 'ui-state-active ui-tabs-selected' : ''; ?>
						<li class="ui-state-default ui-corner-top <?php echo $class; ?>"><?php echo $this->Html->link(__l('My Project Activity'), array('controller' => 'activities', 'action' => 'index', 'type' => 'myproject', 'admin' => false));?></li>
						<?php $class=(!empty($this->request->params['named']['type']) && $this->request->params['named']['type'] == 'backed')?'ui-state-active ui-tabs-selected':'';?>
						<li class="ui-state-default ui-corner-top <?php echo $class; ?>"><?php echo $this->Html->link(__l('Backed Project Activity'), array('controller' => 'activities', 'action' => 'index', 'type' => 'backed', 'admin' => false));?></li>
						<?php  if (Configure::read('Project.is_project_follower_enabled')): ?>
							<?php $class=(!empty($this->request->params['named']['type']) && $this->request->params['named']['type'] == 'follow') ? 'ui-state-active ui-tabs-selected' : ''; ?>
							<li class="ui-state-default ui-corner-top <?php echo $class; ?>"><?php echo $this->Html->link(__l('Following Project Activity'), array('controller' => 'activities', 'action' => 'index', 'type' => 'follow', 'admin' => false));?></li>
						<?php endif; ?>
					<?php endif; ?>
				</ul>
			</div>
		</div>
	<?php } ?>
	<div class="userLogs view-block-proj index js-response">

			<?php 
				if (!empty($activities)) {
					echo $this->element('paging_counter');
				}
			?>

		<ol class="activities-list list clearfix" start="<?php echo $this->Paginator->counter(array('format' => '%start%'));?>">
			<?php
				if (!empty($activities)):
					$i = 0;
					foreach ($activities as $activity):
						$class = null;
						if ($i++ % 2 == 0) {
							$class = 'altrow';
						}
			?>
			<li class="clearfix  <?php echo $class;?>">
				<div class="l-curve-top l-curve-top-in">
					<div class="r-curve-top r-curve-top-in">
						<div class="top-bg top-bg-in"></div>
					</div>
				</div>
					<div class="shad-bg-lft shad-bg-lft-in">
					<div class="shad-bg-rgt shad-bg-rgt-in">
						<div class="shad-bg">
							<div class="activity-main clearfix">
								
								<div class="activity-side1 alpha omega grid_5">
								<div class="project-image <?php if(($activity['project_info']['project_status_id'] == ConstProjectStatus::FundingClosed) || ($activity['project_info']['project_status_id'] == ConstProjectStatus::ProjectCancelled)):?> activity-project-closed <?php endif; ?>">
									<a href="<?php echo $activity['project_info']['url']?>" title="<?php echo $this->Html->cText($activity['project_info']['name'], false); ?>">
									<?php if($activity['project_info']['project_status_id'] == ConstProjectStatus::OpenForIdea ):?>
										<span class="activity-status activity-open-idea"><?php echo __l('Open for voting'); ?></span>
									<?php elseif($activity['project_info']['project_status_id'] == ConstProjectStatus::OpenForFunding ):?>
										<span class="activity-status activity-open-funding"><?php echo __l('Open for funding'); ?></span>
									<?php elseif($activity['project_info']['project_status_id'] == ConstProjectStatus::ReserveAmountReached):?>
										<span class="activity-status activity-amount-reached "><?php echo __l('Reserve amount reached'); ?></span>
									<?php elseif($activity['project_info']['project_status_id'] == ConstProjectStatus::GoalReached):?>
										<span class="activity-status activity-goal-reached"><?php echo __l('Goal reached'); ?></span>
									<?php elseif($activity['project_info']['project_status_id'] == ConstProjectStatus::FundingClosed):?>
										<span class="activity-status activity-closed-funding"><?php echo __l('Funding closed'); ?></span>
									<?php elseif($activity['project_info']['project_status_id'] == ConstProjectStatus::ProjectCancelled):?>
										<span class="activity-status activity-cancelled"><?php echo __l('Cancelled'); ?></span>
									<?php elseif($activity['project_info']['project_status_id'] == ConstProjectStatus::FundingExpired):?>
											<span class="activity-status activity-expired"><?php echo __l('Expired'); ?></span>
									<?php endif; ?>
										<img src="<?php echo $activity['project_info']['image_url']?>" alt="[Image:<?php echo $this->Html->cText($activity['project_info']['name'], false); ?>]"/>
									</a>
									</div>	
									</div>
									<div class="activity-side2 alpha <?php echo (!empty($this->request->params['named']['type']) && $this->request->params['named']['type'] == 'user') ? 'grid_12' : 'grid_17'; ?>">
									<h3>
											<a href="<?php echo $activity['project_info']['url']?>" title="<?php echo $this->Html->cText($activity['project_info']['name'], false); ?>"><?php echo $this->Html->cText($activity['project_info']['name'], false); ?></a>
										<?php if ($activity['activity_info']['model'] == 'Project'): ?>
												<span class="round-3 activity-type status-launched"><?php echo ($activity['activity_info']['action_type'] == 'edit') ? __l('Project edited') : __l('Launched'); ?></span>
										<?php elseif ($activity['activity_info']['model'] == 'ProjectFund'): ?>
												<span class="round-3 activity-type status-pledged"><?php echo __l('Pledged'); ?></span>
										<?php elseif ($activity['activity_info']['model'] == 'ProjectComment'): ?>
												<span class="round-3 activity-type status-commented"><?php echo __l('Commented'); ?></span>
										<?php elseif ($activity['activity_info']['model'] == 'Blog'): ?>
											    <span class="round-3 activity-type status-posted"><?php echo __l('Update posted'); ?></span>
										<?php elseif ($activity['activity_info']['model'] == 'BlogComment'): ?>
												<span class="round-3 activity-type status-updated"><?php echo __l('Commented on update'); ?></span>
										<?php elseif ($activity['activity_info']['model'] == 'ProjectRating'): ?>
												<span class="round-3 activity-type status-rated"><?php echo __l('Voted'); ?></span>
                                        <?php elseif ($activity['activity_info']['model'] == 'ProjectFollower'): ?>
												<span class="round-3 activity-type status-followed"><?php echo __l('Followed'); ?></span>
										<?php endif; ?>
										</h3>
									<div class="clearfix activities-head">
										<span class="grid_left">
											<a href="<?php echo $activity['activity_info']['user_url']?>" title = "<?php echo $this->Html->cText($activity['activity_info']['username'], false); ?>"><img src = "<?php echo $activity['activity_info']['user_image_url']?>" alt="[Image:<?php echo $this->Html->cText($activity['activity_info']['username'], false); ?>]"/></a>
											</span>
											<div class="grid_left">
												<span>
													<a href="<?php echo $activity['activity_info']['user_url']?> " title = "<?php echo $this->Html->cText($activity['activity_info']['username'], false); ?>"> <?php echo $this->Html->cText($activity['activity_info']['username'], false); ?></a> 
												</span>
										<span class="date-block-info"><?php echo $this->Html->cDate($activity['activity_info']['time']);?></span>
										</div>
									</div>
										<address>
											  <?php
												$location = array();
												$place = '';
												if (!empty($activity['project_info']['city_name'])) :
													$location[] = $activity['project_info']['city_name'];
												endif;
												if (!empty($activity['project_info']['state_name'])) :
													$location[] = $activity['project_info']['state_name'];
												endif;
												if (!empty($activity['project_info']['country_name'])) :
													$location[] = $activity['project_info']['country_name'];
												endif;
												$place = implode(', ', $location);
												if ($place):
													if (!empty($activity['project_info']['country_iso2'])):
												?>
												<span class="flags flag-<?php echo strtolower($activity['project_info']['country_iso2']); ?>" title ="<?php echo $activity['project_info']['country_name']; ?>"><?php echo $activity['project_info']['country_name']; ?></span>
												<?php
												endif;
												echo $this->Html->link($place, array('controller' => 'projects', 'action' => 'index', 'city'=>$activity['project_info']['city_slug']), array('escape' => false));
												endif;
												?>
										  </address>
									<div class="clearfix">
										<?php if ($activity['activity_info']['model'] == 'ProjectFund'): ?>
										<?php if (Configure::read('Project.is_show_other_backers_amount_for_backers')): ?>
											<p class="pledge-amount-block"><span class="<?php echo $activity['activity_info']['type']?> amount-info round-5 active-info">
											 <?php echo Configure::read('site.currency') . $this->Html->cCurrency($activity['activity_info']['content']); ?>
											</span></p>
											<?php endif;?>
										<?php elseif ($activity['activity_info']['model'] == 'ProjectRating'): ?>
										<div class="clearfix vote-count grid_left grid_3 omega alpha">
												<ul class="votebg">
												<li>
													<span class="vote-count-value"><?php echo $this->Html->cInt($activity['activity_info']['content'],false); ?></span> <?php echo __l('votes'); ?>
												</li>
												</ul>
												</div>
											
										<?php else: ?>
											<?php if (!empty($activity['activity_info']['title'])) :?>
												<div class="<?php echo $activity['activity_info']['type']; ?> active-info head-highlight"><?php echo $this->Html->cText($activity['activity_info']['title'], false); ?></div>
											<?php endif;?>
											<div class="<?php echo $activity['activity_info']['type']; ?> active-info discussion"><?php echo $this->Html->truncate($this->Html->cText($activity['activity_info']['content'], false),200); ?></div>
										<?php endif; ?>
									</div>
									<?php if (Configure::read('Project.is_project_update_comment_enabled')) : ?>
										<?php if ($activity['activity_info']['type'] == 'content') :?>
											<ol class="comments-block">
												<?php
													if (!empty($activity['activity_info']['blog_comments'])):
														$i = 0;
														foreach($activity['activity_info']['blog_comments'] as $blogComment):
															$class = null;
															if ($i++%2 == 0):
																$class = 'altrow';
															endif;
												?>
												<li class="list-row  clearfix ' . $class . ' comment" id="comment-' . $blogComment['id'] . '">
													<div class="avatar round-3">
														<?php echo $this->Html->getUserAvatar($blogComment['User']['id'], 'small_thumb');?>
														<div class="comments-arrow"></div>
													</div>
													<div class="data user-data round-3">
														<h4>
															<span class="author">
																<?php
																	echo $this->Html->link($this->Html->cText($blogComment['User']['username']) , array('controller' => 'users', 'action' => 'view', $blogComment['User']['username']) , array('title' => $this->Html->cText($blogComment['User']['username'], false), 'escape' => false));
																?>
															</span>
															<?php echo __l('said');?>
														</h4>
														<blockquote><p><?php echo $this->Html->truncate($this->Html->cText($blogComment['comment'],false), 200);?></p></blockquote>
														<p class="meta posted-date"><?php sprintf(__l('posted %s') , $this->Html->cDateTimeHighlight($blogComment['created']));?></p>
													</div>
												</li>
												<?php
														endforeach;
													endif;
												?>
											</ol>
										<?php endif; ?>
									<?php endif; ?>
							
									
										<?php $collected_percentage = ($activity['project_info']['collected_percentage']) ? $activity['project_info']['collected_percentage'] : 0; ?>	
											<?php
												if($collected_percentage>0)
												{
											?>
											<div class="progress-block">
												<p class="progress-bar" title = '<?php echo $this->Html->cFloat($collected_percentage,false).'%'; ?>'>
													<span class="round-5" style="width:<?php echo ($collected_percentage > 100) ? '100%' : $collected_percentage.'%'; ?>;" title = "<?php echo $this->Html->cFloat($collected_percentage,false).'%'; ?>"><?php echo Configure::read('site.currency').$activity['project_info']['collected_amount'];?>
													</span>
												</p>
											</div>
											<?php
											}
											?>
								</div>
								</div>
							</div>
						</div>
					</div>
						<div class="l-curve-bot l-curve-bot-in">
					<div class="r-curve-bot r-curve-bot-in ">
						<div class="bot-bg bot-bg-in "></div>
					</div>
				</div>
			</li>
	<?php
			endforeach;
		else:
	?>
			<li class="main-section">
                <div class="notice-block">
				<p class="notice"><?php echo __l('No activities available');?></p>
				</div>
			</li>
	<?php
		endif;
	?>
		</ol>
		<div class="js-pagination">
		<?php
			if (!empty($activities)) {
				echo $this->element('paging_links');
			}
		?>
		</div>
	</div>
</div>
